#!/usr/bin/env python3

import sys
from collections import Counter

class Person(object):
    def __init__(self, name, grade):
        self.name = name
        self.grade = list(Counter(grade).most_common())

    def get_grade(self):
        if self.name == 'teacher':
            ret = []
            for k, v in self.grade:
                value = k + ": " + str(v)
                ret.append(value)
            return print(", ".join(ret))
        elif self.name == 'student':
            Pass = 0
            Fail = 0
            for k, v in self.grade:
                if k in 'ABC':
                    Pass += v
                else:
                    Fail += v
            return print("Pass: {}, Fail: {}".format(Pass, Fail))
        else:
            print("Error name!")


class Student(Person):
    def __init__(self, name, grade):
        Person.__init__(self, name, grade)
        self.out = Person.get_grade(self)

    def detail(self):
        #return Person.get_grade(self, name, grade)
        return self.out


class Teacher(Person):
    def __init__(self, name, grade):
        Person.__init__(self, name, grade)
        self.out = Person.get_grade(self)

    def detail(self):
        #return Person.get_grade(self, name, grade)
        return self.out

if sys.argv[1] == 'teacher':
    Teacher(sys.argv[1], sys.argv[2]).detail()
elif sys.argv[1] == 'student':
    Student(sys.argv[1], sys.argv[2]).detail()
else:
    print("Err")

